package com.sz.app.oss.api.logistics.order;

import com.sz.app.oss.constants.Permissions;
import com.sz.biz.app.web.BaseController;
import com.sz.common.base.dto.ResultDto;

import com.sz.biz.logistics.ord.service.OrdOrderStatusCodeService;
import com.sz.biz.logistics.ord.dto.OrdOrderStatusCodeDto;
import com.sz.biz.logistics.ord.dto.TrackStatusOperTypeDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Function: 订单物流信息状态code controller
 * Author: yanhong.xiao.<br>
 * Date: 2017-05-15 16:46:00.
 */

@RestController
@RequestMapping("/api/v1/order/statuscodes")
@Api(description = " ", tags = "036-006、订单-物流状态码")
@RequiresPermissions(Permissions.BIZ_MGT_ORD_ORDER)
public class OrdOrderStatusCodeController extends BaseController {

    @Autowired
    private OrdOrderStatusCodeService statusCodeService;


    @ApiOperation(value = "获取所有的物流消息码数据", position = 1)
    @RequestMapping(value = "", method = {RequestMethod.GET})
    public ResultDto getAllStatusCodes() {
        List<OrdOrderStatusCodeDto> list = statusCodeService.getAllCodes();
        ResultDto result = new ResultDto();
        result.setData(list);
        return result;
    }

    @ApiOperation(value = "根据类型获取物流信息编码")
    @RequestMapping(value = "/codetype", method = {RequestMethod.GET})
    public ResultDto getStatusCodesByType() {
        List<Integer> rankList = statusCodeService.getRanks();
        List<TrackStatusOperTypeDto> dtos = statusCodeService.getCodesByType(rankList);
        ResultDto result = new ResultDto(dtos);

        return result;
    }


}
